from pms.common.views import PostFormula
from department.utils import create_department, department_view
from user.models import User


class API(PostFormula):

    require_permissions = [13]

    def handle(self, req):
        return self.success_respond(
            department_view(
                create_department(
                    name=req['name'],
                    user=User.objects.get(id=req['uid'])
                )
            )
        )
